Skip to content

EA.values warning test #20793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

TomAugspurger
Copy link
Contributor

@TomAugspurger TomAugspurger commented Apr 23, 2018

xref #20735 (doesn't close)

Here's a local "test" for it.

pytest pandas/tests/extension/test_values.py -k test_no_values
==================================================================== test session starts ====================================================================
platform darwin -- Python 3.7.0b3, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
rootdir: /Users/taugspurger/sandbox/pandas, inifile: setup.cfg
plugins: xdist-1.22.2, forked-0.2, cov-2.5.1
collected 9 items / 8 deselected

pandas/tests/extension/test_values.py F                                                                                                               [100%]

========================================================================= FAILURES ==========================================================================
______________________________________________________ TestBaseInterfaceTests.test_no_values_attribute ______________________________________________________

self = <pandas.tests.extension.test_values.TestBaseInterfaceTests object at 0x112ed4748>, data = JSONArary([{'A': [1, 2], 'B': [3, 4]}])

    def test_no_values_attribute(self, data):
        # GH-20735
        # Currently, pandas has places where we accepts Union[ndarray, EA]
        # but in practice expect an ndarray, since we get `data.values.dtype`.
        # This warns users to avoid using a `.values` attribute that is not
        # an ndarray-like
        if hasattr(data, 'values') and not hasattr(data.values, 'dtype'):
            msg = ("ExtensionArray contains a 'values' attribute that does "
                   "not have a dtype attribute. This may cause issues in "
                   "pandas' internals.")
>           raise ValueError(msg)
E           ValueError: ExtensionArray contains a 'values' attribute that does not have a dtype attribute. This may cause issues in pandas' internals.

pandas/tests/extension/base/interface.py:64: ValueError
========================================================== 1 failed, 8 deselected in 0.12 seconds ===========================================================

What, if anything, should we include in pandas to test this? I'm fine with the current PR (no tests), since it's just test code.

Edit: ignore what I said about testing. Added one that calls super() inside a raises context manager. It's not too bad.

@TomAugspurger TomAugspurger added Reshaping Concat, Merge/Join, Stack/Unstack, Explode ExtensionArray Extending pandas with custom dtypes or arrays. labels Apr 23, 2018
@TomAugspurger TomAugspurger added this to the 0.23.0 milestone Apr 23, 2018
@TomAugspurger
Copy link
Contributor Author

Closing in favor of #20794

@TomAugspurger TomAugspurger deleted the ea-values-warning branch April 23, 2018 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant